
#ifndef _TTG_SERVICES_DEVICEANALYZER_
#define _TTG_SERVICES_DEVICEANALYZER_

#include "Runtime.Low/Services/Service.h"
#include "CPUAnalyzer.h"

namespace ttg
{
	namespace services
	{
		class DeviceAnalyzer :public ttg::services::Service
		{
			private:
				static DeviceAnalyzer *ref;
			private:
				std::vector<DeviceInfo *> devices;
				DeviceAnalyzer();
			protected:
				//Service member.
				virtual void startUnSafe(std::vector<Service *> &deps, const char *params)
				{ /*nothing*/ }
				//Service member.
				virtual void stopUnSafe()
				{ /*nothing*/ }
			public:
				//Returns reference to CPUAnalyzer.
				inline CPUAnalyzer &_CPUAnalyzer()
				{ return *CPUAnalyzer::getRef(); }
				//Returns information about real devices.
				inline std::vector<DeviceInfo *> &getDevices()
				{ return devices; }
				//Registeres device information, provided by started analyzer.
				//Note: DeviceInfo will not be released by desctructor.
				inline void registerAnalyzer(DeviceInfo *info)
				{ devices.push_back(info); }
				//Unregisters information device information, which was provided by analyzer.
				void unRegisterAnalyzer(DeviceInfo *info);
				//Returns reference to the instance (which always exists).
				inline static DeviceAnalyzer *getRef()
				{ return ref == NULL ? (ref = new DeviceAnalyzer()) : ref; }
		};
	}
}

#endif
